package com.it;

import com.it.service.UserServiceImpl;
import com.it.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class DemoController {

    @Autowired
    UserServiceImpl service;

    // http://localhost:8080/springmvc2/html
    @RequestMapping("/html")
    public String html() {
        System.err.println("html");
        return "index";
    }

    @RequestMapping("/hello")
    @ResponseBody
    public String hello() {
        return "hello ";
    }

    // http://localhost:8080/springmvc2/getUserById?id=1
    @RequestMapping("/getUserById")
    @ResponseBody
    public UserVO getUserById(int id) {
        UserVO vo = new UserVO();
        vo.setId(id);
        vo = service.getUser(vo);
        System.err.println(vo.toString());
        return vo;
    }

}